import '../libs/js/veryless.js';
import '../libs/js/zepto.min.js';
import './index.less';

//import '../libs/js/vconsole.min.js';

import WXConfig from './common/WXConfig.js';

import Swiper from '../libs/swiper/swiper.min';
import SwiperCSS from '../libs/swiper/swiper.min.css';


import Vconsole from 'vconsole/dist/vconsole.min';
import fp from './components/fp.vue';
import result from './components/result.vue';
import face from './components/face.vue';
import hand from './components/hand.vue';
import leg from  './components/leg.vue';
import heart from './components/heart.vue';
import handAni from './components/handAni.vue';
import youKnow from './components/youKnow.vue';
import cicon from './components/icon.vue';
import danmu from './components/danmu.vue';
import jie from './components/jie.vue';
import commodity from './components/commodity.vue';
import loading from './components/loading.vue';
import logo from './components/logo.vue';

import heartImg from '../img/index/heart.png';
import legImg from '../img/index/leg.png';
import handImg from '../img/index/hand.png';
import faceImg from '../img/index/face.png';
import youKnowImg from '../img/index/youknow.png';

const resourcesImg = [heartImg, legImg, handImg, faceImg, youKnowImg];

const v = new Vconsole();
new Vue({
    el: '.app',
    data: {
        resources: resourcesImg,
        pages: [],
        pageType: loading,
        jieImg: '',
        hideLogo: ''
    },
    components: {
        fp,
        result,
        face,
        hand,
        handAni,
        leg,
        heart,
        youKnow,
        danmu,
        cicon,
        jie,
        commodity,
        loading,
        logo
    },
    mounted() {

      console.log('mounted');

      let self = this;
      this.$nextTick(function(){
        $.ajax({
          type: 'GET',
          url: '?c=access_ctrl&m=get_cfg',
          dataType: 'json',
          data: {url:encodeURIComponent(location.href)},
          error: function (error) {
            //alert(JSON.stringify(error));
          },
          success: function (response) {
            if (response.err) {
              //alert(response.err.msg);
              //response.err.sub_msg = decodeURIComponent(response.err.sub_msg);
              //fn.tx(response);
            } else {
              WXConfig.ready(response.data);
              console.log(response.data);
            }
          }
        });
      })

      this.$nextTick(function(){
        $.ajax({
          type: 'GET',
          url: '?c=user_ctrl&m=get_user',
          dataType: 'json',
          data: {},
          error: function (error) {
            console.log('error:', error);
            //alert(JSON.stringify(error));
          },
          success: function (response) {
              console.log('response', response);
            if (response.err) {
              //alert(response.err.msg);
              //response.err.sub_msg = decodeURIComponent(response.err.sub_msg);
              //fn.tx(response);
            } else {
              window.nick = response.data.nick;
              window.headimgurl = response.data.headimgurl;
            }
          }
        });
      })
    },
    methods: {}
});


